package com.dso.portal;


import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.hibernate4.support.OpenSessionInViewInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;

import com.dso.portal.core.platform.DefaultWebConfig;


@Configuration
public class WebConfig extends DefaultWebConfig {

    @Resource(name = "sessionFactory")
    SessionFactory sessionFactory;



    /*@Bean
    public CookieInterceptor cookieInterceptor() {
        return new CookieInterceptor();
    }*/

//    @Bean
//    public LoginInterceptor loginInterceptor() {
//        return new LoginInterceptor();
//    }
    
//    @Bean
//    public TokenInteceptor tokenInteceptor() {
//        return new TokenInteceptor();
//    }
    
//    @Bean
//    public EncodingInteceptor encodingInteceptor() {
//        return new EncodingInteceptor();
//    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        OpenSessionInViewInterceptor   openSessionInViewInterceptor = new OpenSessionInViewInterceptor();
        openSessionInViewInterceptor.setSessionFactory(sessionFactory);
        registry.addWebRequestInterceptor(openSessionInViewInterceptor);


        
        //registry.addInterceptor(cookieInterceptor());
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("forward:/home");
    }

}